using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using AlphaRemoting;

namespace Remoting
{
    public class AlphaRemotingObject
    {
        private readonly IAlphaRemoteObject _iRemoteObject;

        public AlphaRemotingObject(string url)
        {
            ChannelServices.RegisterChannel(new TcpClientChannel(), false);

            _iRemoteObject = RemotingServices.Connect(typeof(IAlphaRemoteObject), url) as IAlphaRemoteObject;
        }

        public string Request(string s)
        {
            string result = string.Empty;
            if (_iRemoteObject != null)
            {
                result = _iRemoteObject.Compute(s);
            }
            return result;
        }
    }
}